#include<iostream>
#include<memory>
#include<functional>

void function1(int token,std::string name,std::string address,std::string phone)
{
    std::cout  << "token:" <<token << "\t" << "name:" << name << "\t" << "address:" << address << "\t" << "telephone:" << phone << std::endl;
}

class TestBind
{
public:
    TestBind(){std::cout << "TestBind consturctor" << std::endl;};
    ~TestBind(){std::cout << "TestBind desturctor" << std::endl;};

    static void Print(std::string name,std::string address,std::string phone){
        std::cout << "name:" << name << "\t" << "address:" << address << "\t" << "telephone:" << phone << std::endl;
    };
private:
};

int main(int argc, char const *argv[])
{

    /*操作全局函数*/
    function1(1,"alang","amoy","15008574624");
    auto bindfunction1 = std::bind(function1,2,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3);
    bindfunction1("alang","amoy","3271405674");
    auto bindfunction2 = std::bind(function1,std::placeholders::_1,"alang",std::placeholders::_2,"3271405674@qq.com");

    bindfunction2(2,"amoy");

    bindfunction2(3,"amoy1");
    bindfunction2(4,"amoy3");
    bindfunction2(5,"amoy4");

    /*****************************************************************/
    /*操作类成员函数*/
    // 绑定类的成员函数,一定要传递对象给bind的第二个参数，可以是类对象，也可以是类对象的指针  ?
    // 如果要修改类成员，必须传递类对象的指针
    auto bindfunction3 = std::bind(&TestBind::Print,std::placeholders::_1,"AMOY","110");
    bindfunction3("阿浪");
    return 0;
}
